﻿using B.Auth.APi.Application.Command.Role;
using B.Auth.Domain.Entity;
using B.Auth.Domain.Repository;
using B.Auth.Enum;
using MediatR;

namespace B.Auth.APi.Application.CommandHand.Role
{
    public class UserselectCommandHand : IRequestHandler<UserselectCommand, ApiResult<List<User>>>
    {
        private readonly IBaseRepository<User> db;

        public UserselectCommandHand(IBaseRepository<User> db)
        {
            this.db = db;
        }

        public Task<ApiResult<List<User>>> Handle(UserselectCommand request, CancellationToken cancellationToken)
        {

            var list = db.GetAll().Where(x => x.departid == request.departid&&x.Del==0).ToList();

            var result = new ApiResult<List<User>>();

            result.data = list;
            return Task.FromResult(result);
            
        }
    }
}
